<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/vue.js"></script>
    <style>
        .hidden {
            display: none;
        }
    </style>
</head>

<body>
    <div id="box">
        {{message}}
        <!-- 传统写法 -->
        <button onclick="handleClick()">click</button>
        <!-- vue写法 -->
        <button v-on:click="vuehandleClick()">vue click</button>
        <!-- 简写 -->
        <button @click="vuehandleClick()">vue click</button>
        <!-- 指令 -->
        <div :class="isShow?'':'hidden'">我是显示或隐藏</div>
    </div>
    <script>
        // 传统写法
        function handleClick() {
            alert('click')
            app.message = 'hello'

        }
        //vue写法
        // vue写法
        var obj = {
            data() {
                return {
                    message: 'hello world',
                    isShow: true
                }
            },
            methods: {
                // vue写法
                vuehandleClick() {
                    this.message = 'hello VUE!'
                    this.isShow = !this.isShow
                }
            }
        }
        var app = Vue.createApp(obj).mount('#box')
    </script>
</body>

</html>